<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="text" placeholder="请输入" />
    <script>
      // let timeId = null
      // document.querySelector('input').oninput = e => {
      //   clearTimeout(timeId)
      //   timeId = setTimeout(() => {
      //     console.log(e.target.value)
      //   }, 500)
      // }
      let lastTime = null
      let count = 0
      window.onmousemove = function (e) {
        let time = Date.now()
        if (time - lastTime > 1000) {
          count++
          console.log('触发了 ' + count + ' 次')
          lastTime = time
        }
      }
    </script>
  </body>
</html>
